﻿using Entitas;

public class ArriveToDieSystem : IExecuteSystem
{
    public void Execute()
    {
        var entities = Contexts.sharedInstance.game
            .GetGroup(GameMatcher.AllOf(GameMatcher.ArriveToDie, GameMatcher.Transform))
            .GetEntities();

        foreach (var e in entities)
        {
            if ((e.arriveToDie.destination - e.transform.position).sqrMagnitude < GameDefine.WAY_POINT_SEEK_DIST_SQ)
            {
                e.isDestroyed = true;
            }
        }
    }
}